import unittest
from ddt import ddt, data
from openpyxl import load_workbook


class Case:
    def __init__(self):
        self.case_id = None
        self.title = None
        self.url = None
        self.data = None
        self.method = None
        self.expected = None
        self.sql = None


class Do_Excel:
    def __init__(self, filename, sheet_name):
        self.filename = filename
        self.fn = load_workbook(self.filename )  # 打开文件
        self.sheet_name = sheet_name
        self.sheet = self.fn[self.sheet_name]

    # 写入文件
    def write_excel(self, h, l, val):
        self.sheet.cell(h, l).value = val  # 执行结果
        self.fn.save(filename=self.filename)
        self.fn.close()

    # 获取文件已有行数


if __name__ == '__main__':
    # 写入
    excel = Do_Excel("../report/report.xlsx", 'Sheet1')
    excel.write_excel(l=1, h=2, val="11")
    excel.write_excel(l=2, h=2, val="02")
    excel.write_excel(l=3, h=2, val="03")
    excel.write_excel(l=4, h=2, val="04")
    excel.write_excel(l=5, h=2, val="05")
